package cn.com.generaldata.os.service.indicator_evaluation.national_economy_contribution;

import org.apache.commons.lang3.Validate;

import cn.com.generaldata.jsme_indicator_system.entity.IndicatorEvaluation;
import cn.com.generaldata.os.service.indicator_constant.ProvinceIndicatorConstant;
import cn.com.generaldata.os.service.indicator_evaluation.IndicatorEvaluationCalculateService;
import cn.com.generaldata.os.vo.IndicatorAccountVO;

/**
 * 海洋经济直接贡献率评估指标计算类.
 */
public class MECCalculateService extends IndicatorEvaluationCalculateService {

	private String GOPIndicatorName = ProvinceIndicatorConstant.GOP_INDICATOR_NAME;
	private String GDPIndicatorName = ProvinceIndicatorConstant.GDP_INDICATOR_NAME;

	@Override
	protected Double calculate(IndicatorEvaluation indicator, IndicatorAccountVO indicatorAccountVO) {
		Double GOP = getInputOrAccountingIndicatorValue(indicatorAccountVO, indicatorAccountVO.getYear(),
				GOPIndicatorName);
		Validate.isTrue(GOP != null);
		Double lastGOP = getInputOrAccountingIndicatorValue(indicatorAccountVO, indicatorAccountVO.getYear() - 1,
				GOPIndicatorName);
		Validate.isTrue(lastGOP != null);
		Double GDP = getInputOrAccountingIndicatorValue(indicatorAccountVO, indicatorAccountVO.getYear(),
				GDPIndicatorName);
		Validate.isTrue(GDP != null);
		Double lastGDP = getInputOrAccountingIndicatorValue(indicatorAccountVO, indicatorAccountVO.getYear() - 1,
				GDPIndicatorName);
		Validate.isTrue(lastGDP != null);

		return (GOP - lastGOP) / (GDP - lastGDP) * 100;
	}

}
